<template>
	<view class="login_main">
		<!-- <view class="login_bg1"></view>
		<view class="login_bg2"></view>
		<view class="lolgin_top"></view> -->
		<view class="login_main_main"><text class="t11">收款码</text>
			<view class="yqm">
				<image :src="src" mode="widthFix"></image>
			</view>
			<view class="tuic1 t12" @click="baocun()">保存收款码</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mainid: '',
				src: '',
				yqm: '',
			}
		},
		onLoad() {

			var _this = this;
			uni.getStorage({
				key: 'user',
				success: function(res) {
					_this.mainid = res.data.id;
					_this.ewm();
				}
			});
		},
		methods: {
			baocun() {
				// this.src='https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1730713693,2130926401&fm=26&gp=0.jpg';
				uni.downloadFile({
						url:this.src,
						success: (res) =>{
							if (res.statusCode === 200){
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success: function() {
										uni.showToast({
											title: "保存成功",
											icon: "none"
										});
									},
									fail: function() {
										uni.showToast({
											title: "保存失败，请稍后重试",
											icon: "none"
										});
									}
								});
							}
						}
					})
				// uni.saveImageToPhotosAlbum({
				// 	filePath: this.src,
				// 	success: function() {
				// 		console.log('保存图片成功');
				// 	}
				// });
			},
			ewm() {
				var that = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'mch/getPayQRCode/'+that.mainid, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						id: that.mainid
					},
					success: (res) => {
						uni.hideLoading(); //关闭加载动画
						console.log(res);
						if (res.data.status == '200') {
							// that.yqm = res.data.data.shareCode;
							that.src = res.data.data;
						}
					},
					fail: (error) => {
						// this.checks = true
						console.log(error)
					}
				});
			},
		}
	}
</script>

<style>
	.login_main {

		width: 100%;
		height: auto;
		min-height: 100vh;
		max-height: 220vw;
		display: block;
		float: left;
		/* 	background: url(../../static/img/login.png) no-repeat top center; */
		background: #000000;
		background-size: auto 100%;
	}

	.login_main_main {
		width: 80%;
		height: auto;
		display: block;
		float: left;
		margin: 0 10%;
		top: 40vw;
		background: #FFFFFF;
		border-radius: 7vw;
		position: fixed;
		z-index: 99;
		padding: 10vw 0;
	}

	.login_main_main text {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		text-align: center;
	}
	.yqm {
		width: 70vw;
		height: 70vw;
		display: block;
		float: left;
		background: #eee;
		margin: 4vw 5vw;
	}
.yqm image{width:70vw;height:70vw;display: block;float: left;}

	.login_main_zhu {
		width: 54.5vw;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
		margin: 1vw 12.8vw;
	}

	.login_main_zhuce {
		width: auto;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
	}

	.login_main_wangji {
		width: auto;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: right;
	}

	.login_main_but {
		width: 64.8vw;
		height: 13vw;
		display: block;
		float: left;
		margin: 2vw 7.6vw;
		line-height: 13vw;
		text-align: center;
		background: #f1c75e;
		border-radius: 6.5vw;
		background-size: 100%;
	}

	.login_zd {
		width: 100%;
		height: auto;
		display: block;
		float: left;
	}

	.login_zd_t {
		width: 4vw;
		height: 4vw;
		border: 1px solid #f1c75e;
		margin-left: 8vw;
		margin-top: 4vw;
		display: block;
		float: left;
	}

	.login_zd text {
		width: auto;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
		margin-top: 2vw;
		margin-left: 3vw;
	}

	.act {
		background: #f1c75e;
	}

	.login_bg1 {
		width: 50vw;
		height: 50vw;
		border-radius: 50%;
		position: fixed;
		background: #F1C75E;
		right: -10vw;
		top: -15vw;
		z-index: 1;
	}

	.login_bg2 {
		width: 120vw;
		height: 200vw;
		border-radius: 50%;
		position: fixed;
		background: #F1C75E;
		right: -40vw;
		top: 0vw;
		z-index: 1;
		opacity: 0.5;
	}

	.lolgin_top {
		width: auto;
		height: auto;
		position: fixed;
		top: 20vw;
		left: 10vw;
	}

	.lolgin_top font {
		width: 100%;
		height: auto;
		display: block;
		float: left;
	}
</style>
